/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Inrterface;

import Map.MapConfig;
import jcgame.Main;
import net.slashie.libjcsi.CSIColor;

/**
 *
 * @author insane
 */
public class Interface {

    public void draw() {
        MapConfig mc = MapConfig.getInstance();

        this.drawHorizontalLine(
                mc.getPadding_left() - 2,
                mc.getPadding_top() - 2,
                mc.getScreenWidth(),
                CSIColor.SILVER);
        this.drawHorizontalLine(
                mc.getPadding_left() - 2,
                mc.getScreenHeight() - 1,
                mc.getScreenWidth(),
                CSIColor.SILVER);
        this.drawVerticalLine(
                mc.getPadding_top() - 2,
                mc.getPadding_left() - 2,
                mc.getScreenHeight(),
                CSIColor.SILVER);
        this.drawVerticalLine(
                mc.getPadding_top() - 2,
                mc.getScreenWidth() - 1,
                mc.getScreenHeight(),
                CSIColor.SILVER);

        //map panel
        this.drawHorizontalLine(
                mc.getPadding_left() - 1,
                mc.getPadding_top() - 1,
                mc.getPadding_left() + mc.getViewSizeWidth() * 2 + 1,
                CSIColor.SILVER);
        this.drawHorizontalLine(
                mc.getPadding_left() - 1,
                mc.getPadding_top() + mc.getViewSizeHeight() * 2,
                mc.getPadding_left() + mc.getViewSizeWidth() * 2 + 1,
                CSIColor.SILVER);
        this.drawVerticalLine(
                mc.getPadding_top() - 1,
                mc.getPadding_left() + mc.getViewSizeWidth() * 2,
                mc.getPadding_top() + mc.getViewSizeHeight() * 2 + 1,
                CSIColor.SILVER);
        this.drawVerticalLine(
                mc.getPadding_top() - 1,
                mc.getPadding_left() - 1,
                mc.getPadding_top() + mc.getViewSizeHeight() * 2 + 1,
                CSIColor.SILVER);

        //message panel
        this.drawHorizontalLine(
                mc.getPadding_left() - 1,
                mc.getPadding_top() + mc.getViewSizeHeight() * 2 + 1,
                mc.getPadding_left() + mc.getViewSizeWidth() * 2 + 1,
                CSIColor.SILVER);
        this.drawHorizontalLine(
                mc.getPadding_left() - 1,
                mc.getScreenHeight() - 2,
                mc.getPadding_left() + mc.getViewSizeWidth() * 2 + 1,
                CSIColor.SILVER);
        this.drawVerticalLine(
                mc.getPadding_top() + mc.getViewSizeHeight() * 2 + 1,
                mc.getPadding_left() - 1,
                mc.getScreenHeight() - 1,
                CSIColor.SILVER);
        this.drawVerticalLine(
                mc.getPadding_top() + mc.getViewSizeHeight() * 2 + 1,
                mc.getPadding_left() + mc.getViewSizeWidth() * 2 ,
                mc.getScreenHeight() - 1,
                CSIColor.SILVER);
        /*this.drawVerticalLine(
        mc.getScreenHeight() * 2 + mc.getPadding_top() + 1,
        mc.getPadding_left() - 1,
        mc.getScreenHeight() - 1,
        CSIColor.SILVER);
        /*
        //message panel
        this.drawHorizontalLine(32, 1, 79, CSIColor.SILVER);
        this.drawHorizontalLine(32, 23, 79, CSIColor.SILVER);
        this.drawVerticalLine(1, 32, 24, CSIColor.SILVER);
        this.drawVerticalLine(1, 78, 24, CSIColor.SILVER);
         */
    }

    public void drawHorizontalLine(int startx, int y, int endx, CSIColor cc) {
        for (int a = 0; a < endx - startx; a++) {
            if (a == 0 || a == endx - startx - 1) {
                Main.csi.print(startx + a, y, '+', cc);
            } else {
                Main.csi.print(startx + a, y, '-', cc);
            }
        }
    }

    public void drawVerticalLine(int starty, int x, int endy, CSIColor cc) {
        for (int a = 0; a < endy - starty; a++) {
            if (a == 0 || a == endy - starty - 1) {
                Main.csi.print(x, starty + a, '+', cc);
            } else {
                Main.csi.print(x, starty + a, '|', cc);
            }
        }
    }

    public void dot(int x, int y, CSIColor cc) {
        Main.csi.print(x, y, '+', cc);
    }

    public void background(int x, int y, CSIColor cc) {
        Main.csi.print(x, y, '■', cc);
    }
}
